package com.ccys.app.controller;


import com.ccys.app.service.MemberPreAuthenticationService;
import com.ccys.app.service.MemberService;
import com.ccys.common.constants.ContextConstants;
import com.ccys.common.constants.TouristApi;
import com.ccys.common.vo.ResponseResultApp;
import com.ccys.db.dto.login.*;
import com.ccys.db.dto.member.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@Api(tags = "病人注册认证流程")
@RequestMapping("Member")
public class MemberPreAuthenticationController {

    @Autowired
    private MemberPreAuthenticationService memberPreAuthenticationService;



    @TouristApi
    @ApiOperation("忘记密码")
    @PostMapping(value = "/ForgotPassword")
    @ApiResponses({
            @ApiResponse(code = 411, message = ContextConstants.DESC_411),
            @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp ForgotPassword(ForgotPasswordDto dto){
        return this.memberPreAuthenticationService.forgotPassword(dto);
    }


    @TouristApi
    @ApiOperation("重置密码")
    @PostMapping(value = "/ResetPassword")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp resetPassword(ResetPasswordDto dto){
        return this.memberPreAuthenticationService.resetPassword(dto);
    }

    @TouristApi
    @ApiOperation("病人注册")
    @PostMapping(value = "/Register")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp register(RegisterDto dto){
        return this.memberPreAuthenticationService.register(dto);
    }

    @TouristApi
    @ApiOperation("请求一次性校验（短信）")
    @PostMapping(value = "/RequestOTP")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp RequestOTP(RequestOTPDto dto){
        return this.memberPreAuthenticationService.requestOTP(dto);
    }


    @TouristApi
    @ApiOperation("激活账号（短信）")
    @PostMapping(value = "/ActivateAccount")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp ActivateAccount(ActivateAccountDto dto){
        return this.memberPreAuthenticationService.activateAccount(dto);
    }

    @ApiOperation("登录状态下 的发送pincode邮件验证码")
    @PostMapping(value = "/RequestPinCode")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp RequestPinCode(RequestPinCodeDto dto){
        return this.memberPreAuthenticationService.requestPinCode(dto);
    }

    @ApiOperation("登录状态下 的发送pincode短信验证码")
    @PostMapping(value = "/RequestPinCodeViaSMS")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp RequestPinCodeViaSMS(String key){
        return this.memberPreAuthenticationService.requestPinCodeViaSMS(key);
    }

    @ApiOperation("激活pingcode")
    @PostMapping(value = "/ActivatePinCode")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp ActivatePinCode(ActivatePinCodeDto dto){
        return this.memberPreAuthenticationService.activatePinCode(dto);
    }


    @ApiOperation("修改密码")
    @PostMapping(value = "/UpdatePassword")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp UpdatePassword(UpdatePasswordDto dto){
        return this.memberPreAuthenticationService.updatePassword(dto);
    }



    @ApiOperation("获取视频的AccessToken")
    @GetMapping(value = "/GetTwilioToken")
    @ApiResponses({
        @ApiResponse(code = 411, message = ContextConstants.DESC_411),
        @ApiResponse(code = 200, message = ContextConstants.MODEL_DESC,response = ResponseResultApp.class),
    })
    public ResponseResultApp GetTwilioToken(GetTwilioTokenDto dto){
        return this.memberPreAuthenticationService.getTwilioToken(dto);
    }


}
